/* 
	This abstract mediator is the way Cliff used to slove the problem of popups.
	
	Usage: Mediators that need to invoke popups extend it.
	URL: http://forums.puremvc.org/index.php?topic=105.0
*/
package com.anyisn.puremvc.as3.patterns.mediator
{
	import flash.display.Sprite;
	
	import mx.core.Application;
	import mx.core.IFlexDisplayObject;
	import mx.managers.PopUpManager;
	
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	import com.anyisn.anyflickr.shell.ShellFacade;

	public class AbstractPopupMediator extends Mediator
	{
		public function AbstractPopupMediator(mediatorName:String=null, viewComponent:Object=null)
		{
			super(mediatorName, viewComponent);
		}
		
		protected static function openPopUpWindow(ComponentClass:Class, MediatorClass:Class):void {
			var window:IFlexDisplayObject = PopUpManager.createPopUp(Application.application as Sprite, ComponentClass, true);
			
			ShellFacade.getInstance().registerMediator(new MediatorClass(window));
			PopUpManager.centerPopUp(window);
		}
		
		protected static function closePopUpWindow(window:IFlexDisplayObject, mediatorName:String):void {
			PopUpManager.removePopUp(window);
			ShellFacade.getInstance().removeMediator(mediatorName);
		}
		
	}
}